package app.interfacegrafica;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.imageio.ImageIO;
import javax.swing.UIManager;

/**
 *
 * @author multi
 */
public class Interface extends javax.swing.JFrame {

    /** Creates new form Show */
    public Interface() {
        initComponents();

        BufferedImage icone = null;
        try {
            icone = ImageIO.read(getClass().getResource("/pixmap/samir_sp_boka.png"));
            setIconImage(icone);
        } catch (IOException e) {
            System.out.println("Erro ao carregar o ícone do JFrame.\n" + e);
        }

        try {
            InetAddress endereco = InetAddress.getLocalHost();
            if (!endereco.isLoopbackAddress()) {
                ip.setText("Seu IP: " + endereco.getHostAddress());
            } else {
                ip.setText("Não foi possível obter seu IP.");
            }
        } catch (UnknownHostException e) {
            ip.setText("Não foi possível obter seu IP.");
        }

        painelEscolha.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        maoJogador = new javax.swing.JPanel();
        peca0 = new javax.swing.JButton();
        peca1 = new javax.swing.JButton();
        peca2 = new javax.swing.JButton();
        peca3 = new javax.swing.JButton();
        peca4 = new javax.swing.JButton();
        peca5 = new javax.swing.JButton();
        peca6 = new javax.swing.JButton();
        peca7 = new javax.swing.JButton();
        peca8 = new javax.swing.JButton();
        peca9 = new javax.swing.JButton();
        peca10 = new javax.swing.JButton();
        peca11 = new javax.swing.JButton();
        peca12 = new javax.swing.JButton();
        peca13 = new javax.swing.JButton();
        peca14 = new javax.swing.JButton();
        peca15 = new javax.swing.JButton();
        peca16 = new javax.swing.JButton();
        peca17 = new javax.swing.JButton();
        peca18 = new javax.swing.JButton();
        peca19 = new javax.swing.JButton();
        peca20 = new javax.swing.JButton();
        painelEscolha = new javax.swing.JPanel();
        jogada = new javax.swing.JLabel();
        jogar = new javax.swing.JButton();
        pecaEscolhida = new javax.swing.JButton();
        painelTitulo = new javax.swing.JPanel();
        flag = new javax.swing.JLabel();
        ip = new javax.swing.JLabel();
        titulo = new javax.swing.JLabel();
        tabuleiro = new javax.swing.JPanel();
        p0 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Dominó Online");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(650, 550));

        maoJogador.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Suas peças", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 1, 13))); // NOI18N
        maoJogador.setAutoscrolls(true);

        peca0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca0ActionPerformed(evt);
            }
        });

        peca1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca1ActionPerformed(evt);
            }
        });

        peca2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca2ActionPerformed(evt);
            }
        });

        peca3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca3ActionPerformed(evt);
            }
        });

        peca4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca4ActionPerformed(evt);
            }
        });

        peca5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca5ActionPerformed(evt);
            }
        });

        peca6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca6ActionPerformed(evt);
            }
        });

        peca7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca7ActionPerformed(evt);
            }
        });

        peca8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca8ActionPerformed(evt);
            }
        });

        peca9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca9ActionPerformed(evt);
            }
        });

        peca10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca10ActionPerformed(evt);
            }
        });

        peca11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca11ActionPerformed(evt);
            }
        });

        peca12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca12ActionPerformed(evt);
            }
        });

        peca13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca13ActionPerformed(evt);
            }
        });

        peca14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca14ActionPerformed(evt);
            }
        });

        peca15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca15ActionPerformed(evt);
            }
        });

        peca16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca16ActionPerformed(evt);
            }
        });

        peca17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca17ActionPerformed(evt);
            }
        });

        peca18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca18ActionPerformed(evt);
            }
        });

        peca19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca19ActionPerformed(evt);
            }
        });

        peca20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        peca20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                peca20ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout maoJogadorLayout = new javax.swing.GroupLayout(maoJogador);
        maoJogador.setLayout(maoJogadorLayout);
        maoJogadorLayout.setHorizontalGroup(
            maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(maoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(maoJogadorLayout.createSequentialGroup()
                        .addComponent(peca0, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca2, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca3, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca4, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca5, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca6, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                    .addGroup(maoJogadorLayout.createSequentialGroup()
                        .addComponent(peca13, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca11, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca10, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca9, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca8, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca7, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))
                    .addGroup(maoJogadorLayout.createSequentialGroup()
                        .addComponent(peca20, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca18, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca17, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca16, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca15, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(peca14, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)))
                .addContainerGap())
        );
        maoJogadorLayout.setVerticalGroup(
            maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(maoJogadorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(peca6)
                    .addComponent(peca5)
                    .addComponent(peca4)
                    .addComponent(peca3)
                    .addComponent(peca2)
                    .addComponent(peca1)
                    .addComponent(peca0))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(peca7)
                    .addComponent(peca8)
                    .addComponent(peca9)
                    .addComponent(peca10)
                    .addComponent(peca11)
                    .addComponent(peca12)
                    .addComponent(peca13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(maoJogadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(peca14)
                    .addComponent(peca15)
                    .addComponent(peca16)
                    .addComponent(peca17)
                    .addComponent(peca18)
                    .addComponent(peca19)
                    .addComponent(peca20))
                .addGap(81, 81, 81))
        );

        jogada.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jogada.setText("Peça escolhida:");
        jogada.setToolTipText("Clique em uma de suas peças ao lado para jogar.");

        jogar.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jogar.setText("Jogar!");
        jogar.setToolTipText("Confirmar a sua jogada.");
        jogar.setAutoscrolls(true);
        jogar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jogarActionPerformed(evt);
            }
        });

        pecaEscolhida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        pecaEscolhida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pecaEscolhidaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout painelEscolhaLayout = new javax.swing.GroupLayout(painelEscolha);
        painelEscolha.setLayout(painelEscolhaLayout);
        painelEscolhaLayout.setHorizontalGroup(
            painelEscolhaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelEscolhaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(painelEscolhaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(pecaEscolhida)
                    .addComponent(jogada)
                    .addComponent(jogar, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        painelEscolhaLayout.setVerticalGroup(
            painelEscolhaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelEscolhaLayout.createSequentialGroup()
                .addComponent(jogada)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(pecaEscolhida)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jogar)
                .addGap(6, 6, 6))
        );

        jogar.getAccessibleContext().setAccessibleDescription("Fazer a jogada.");

        flag.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        flag.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/flag_red.png"))); // NOI18N
        flag.setText("Aguardando o outro jogador.");
        flag.setToolTipText("Indica o status do jogo.");

        ip.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        ip.setText("Seu IP: 192.168.254.1");

        titulo.setFont(new java.awt.Font("DejaVu Sans", 1, 18));
        titulo.setText("Dominó Online");

        javax.swing.GroupLayout painelTituloLayout = new javax.swing.GroupLayout(painelTitulo);
        painelTitulo.setLayout(painelTituloLayout);
        painelTituloLayout.setHorizontalGroup(
            painelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelTituloLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titulo)
                .addGap(204, 204, 204)
                .addGroup(painelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(flag, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, painelTituloLayout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(ip, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        painelTituloLayout.setVerticalGroup(
            painelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelTituloLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(titulo)
                    .addGroup(painelTituloLayout.createSequentialGroup()
                        .addComponent(flag)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
                        .addComponent(ip)))
                .addContainerGap())
        );

        tabuleiro.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Tabuleiro", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 1, 13))); // NOI18N
        tabuleiro.setAutoscrolls(true);
        tabuleiro.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabuleiroMouseClicked(evt);
            }
        });

        p0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pixmap/depeis/0-0.gif"))); // NOI18N
        p0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                p0ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tabuleiroLayout = new javax.swing.GroupLayout(tabuleiro);
        tabuleiro.setLayout(tabuleiroLayout);
        tabuleiroLayout.setHorizontalGroup(
            tabuleiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 567, Short.MAX_VALUE)
            .addGroup(tabuleiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(tabuleiroLayout.createSequentialGroup()
                    .addGap(260, 260, 260)
                    .addComponent(p0, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(260, Short.MAX_VALUE)))
        );
        tabuleiroLayout.setVerticalGroup(
            tabuleiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 121, Short.MAX_VALUE)
            .addGroup(tabuleiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(tabuleiroLayout.createSequentialGroup()
                    .addGap(25, 25, 25)
                    .addComponent(p0)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tabuleiro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(maoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                        .addComponent(painelEscolha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(painelTitulo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(painelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(tabuleiro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addComponent(maoJogador, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE))
                    .addComponent(painelEscolha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        getAccessibleContext().setAccessibleDescription("Dominó Online");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jogarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jogarActionPerformed
        // TODO ação do botão jogar
    }//GEN-LAST:event_jogarActionPerformed

    private void peca0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca0ActionPerformed
        if (peca0.isEnabled()) {
            pecaEscolhida.setIcon(peca0.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca0ActionPerformed

    private void pecaEscolhidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pecaEscolhidaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pecaEscolhidaActionPerformed

    private void peca1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca1ActionPerformed
        if (peca1.isEnabled()) {
            pecaEscolhida.setIcon(peca1.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca1ActionPerformed

    private void peca2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca2ActionPerformed
        if (peca2.isEnabled()) {
            pecaEscolhida.setIcon(peca2.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca2ActionPerformed

    private void peca3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca3ActionPerformed
        if (peca3.isEnabled()) {
            pecaEscolhida.setIcon(peca3.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca3ActionPerformed

    private void peca4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca4ActionPerformed
        if (peca4.isEnabled()) {
            pecaEscolhida.setIcon(peca4.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca4ActionPerformed

    private void peca5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca5ActionPerformed
        if (peca5.isEnabled()) {
            pecaEscolhida.setIcon(peca5.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca5ActionPerformed

    private void peca6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca6ActionPerformed
        if (peca6.isEnabled()) {
            pecaEscolhida.setIcon(peca6.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca6ActionPerformed

    private void peca7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca7ActionPerformed
        if (peca7.isEnabled()) {
            pecaEscolhida.setIcon(peca7.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca7ActionPerformed

    private void peca8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca8ActionPerformed
        if (peca8.isEnabled()) {
            pecaEscolhida.setIcon(peca8.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca8ActionPerformed

    private void peca9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca9ActionPerformed
        if (peca9.isEnabled()) {
            pecaEscolhida.setIcon(peca9.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca9ActionPerformed

    private void peca10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca10ActionPerformed
        if (peca10.isEnabled()) {
            pecaEscolhida.setIcon(peca10.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca10ActionPerformed

    private void peca11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca11ActionPerformed
        if (peca11.isEnabled()) {
            pecaEscolhida.setIcon(peca11.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca11ActionPerformed

    private void peca12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca12ActionPerformed
        if (peca12.isEnabled()) {
            pecaEscolhida.setIcon(peca12.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca12ActionPerformed

    private void peca13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca13ActionPerformed
        if (peca13.isEnabled()) {
            pecaEscolhida.setIcon(peca13.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca13ActionPerformed

    private void peca14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca14ActionPerformed
        if (peca14.isEnabled()) {
            pecaEscolhida.setIcon(peca14.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca14ActionPerformed

    private void peca15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca15ActionPerformed
        if (peca15.isEnabled()) {
            pecaEscolhida.setIcon(peca15.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca15ActionPerformed

    private void peca16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca16ActionPerformed
        if (peca16.isEnabled()) {
            pecaEscolhida.setIcon(peca16.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca16ActionPerformed

    private void peca17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca17ActionPerformed
        if (peca17.isEnabled()) {
            pecaEscolhida.setIcon(peca17.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca17ActionPerformed

    private void peca18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca18ActionPerformed
        if (peca18.isEnabled()) {
            pecaEscolhida.setIcon(peca18.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca18ActionPerformed

    private void peca19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca19ActionPerformed
        if (peca19.isEnabled()) {
            pecaEscolhida.setIcon(peca19.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca19ActionPerformed

    private void peca20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_peca20ActionPerformed
        if (peca20.isEnabled()) {
            pecaEscolhida.setIcon(peca20.getIcon());
            painelEscolha.setVisible(true);
        }
    }//GEN-LAST:event_peca20ActionPerformed

    private void tabuleiroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabuleiroMouseClicked
        System.out.println(p0.getSize());
        IconeRotacionado pi0 = new IconeRotacionado(p0.getIcon(), 90.0);
//        Dimension dim = new Dimension(84, 47);
        p0.setSize(84, 47);

        p0.setIcon(pi0);
    }//GEN-LAST:event_tabuleiroMouseClicked

    private void p0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_p0ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_p0ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void run() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (Exception e) {
                }
                new Interface().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel flag;
    private javax.swing.JLabel ip;
    private javax.swing.JLabel jogada;
    private javax.swing.JButton jogar;
    private javax.swing.JPanel maoJogador;
    private javax.swing.JButton p0;
    private javax.swing.JPanel painelEscolha;
    private javax.swing.JPanel painelTitulo;
    private javax.swing.JButton peca0;
    private javax.swing.JButton peca1;
    private javax.swing.JButton peca10;
    private javax.swing.JButton peca11;
    private javax.swing.JButton peca12;
    private javax.swing.JButton peca13;
    private javax.swing.JButton peca14;
    private javax.swing.JButton peca15;
    private javax.swing.JButton peca16;
    private javax.swing.JButton peca17;
    private javax.swing.JButton peca18;
    private javax.swing.JButton peca19;
    private javax.swing.JButton peca2;
    private javax.swing.JButton peca20;
    private javax.swing.JButton peca3;
    private javax.swing.JButton peca4;
    private javax.swing.JButton peca5;
    private javax.swing.JButton peca6;
    private javax.swing.JButton peca7;
    private javax.swing.JButton peca8;
    private javax.swing.JButton peca9;
    private javax.swing.JButton pecaEscolhida;
    private javax.swing.JPanel tabuleiro;
    private javax.swing.JLabel titulo;
    // End of variables declaration//GEN-END:variables
}
